package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.HouInfo;
import com.ruoyi.mes.service.IHouInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库房管理Controller
 *
 * @author LongAndHao
 * @date 2023-04-04
 */
@Api(tags = "库房管理")
@RestController
@RequestMapping("/mes/houinfo")
public class HouInfoController extends BaseController {
    @Autowired
    private IHouInfoService houInfoService;

    /**
     * 查询库房管理列表
     */
    @ApiOperation(value = "查询库房管理列表")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouInfo houInfo) {
        startPage();
        List<HouInfo> list = houInfoService.selectHouInfoList(houInfo);
        return getDataTable(list);
    }

    /**
     * 导出库房管理列表
     */
    @ApiOperation(value = "导出库房管理列表")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:export')")
    @Log(title = "库房管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouInfo houInfo) {
        List<HouInfo> list = houInfoService.selectHouInfoList(houInfo);
        ExcelUtil<HouInfo> util = new ExcelUtil<HouInfo>(HouInfo.class);
        util.exportExcel(response, list, "库房管理数据");
    }

    /**
     * 获取库房管理详细信息
     */
    @ApiOperation(value = "获取库房管理详细信息")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:query')")
    @GetMapping(value = "/{houId}")
    public AjaxResult getInfo(@PathVariable("houId") Long houId) {
        return success(houInfoService.selectHouInfoByHouId(houId));
    }

    /**
     * 新增库房管理
     */
    @ApiOperation(value = "新增库房管理")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:add')")
    @Log(title = "库房管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouInfo houInfo) {
        return toAjax(houInfoService.insertHouInfo(houInfo));
    }

    /**
     * 修改库房管理
     */
    @ApiOperation(value = "修改库房管理")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:edit')")
    @Log(title = "库房管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouInfo houInfo) {
        return toAjax(houInfoService.updateHouInfo(houInfo));
    }

    /**
     * 删除库房管理
     */
    @ApiOperation(value = "删除库房管理")
    @PreAuthorize("@ss.hasPermi('mes:houinfo:remove')")
    @Log(title = "库房管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{houIds}")
    public AjaxResult remove(@PathVariable Long[] houIds) {
        return toAjax(houInfoService.deleteHouInfoByHouIds(houIds));
    }
}
